<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>消息列表</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  
    {include file="public/css"}
    {include file="public/js"}
    <script>
layui.use('layer', function(){
  var layer = layui.layer;
      //页面层
 
 
});   
    $(function(){

      $(".title").on('click',function(){
           
       var url  =  $(this).attr('data-url');

           layer.open({
          type: 2,
          title: '查看消息内容',
          shadeClose: true,
          shade: false,
          // maxmin: true, //开启最大化最小化按钮
          area: ['800px', '300px'],
          content: url
    });     
      });
    });


    </script>
</head>
<body>

<!-- 后台面包屑导航 -->
{:get_admin_breadcrumb()}

<!-- 搜索表单 -->
{:create_search_form("",$keywordsData,$customSingleField,$groupData,$dateData,$orderData)}
<div class="layui-tab layui-tab-brief">
  <ul class="layui-tab-title">
    <li><a href="{:url('message/index')}" {if $type == ''}class="layui-this"{/if}>全部消息</a></li>
    <li><a href="{:url('message/index',['type'=>'1'])}" {if $type == '1'}class="layui-this"{/if}>通知</a></li>
  </ul>

</div>



<div class="layui-form">
  <table class="layui-table" id="demo">
    <colgroup>
      <col width="50">
      <col width="20">
      <col width="110">
      <col>
    </colgroup>
    <thead>

      <tr>
        <th><input type="checkbox"  id="selectAll"  lay-skin="primary" lay-filter="selectAll"></th>
        <th>图标</th>
        <th>消息类型</th>
        <th>消息标题</th>
        <th>发信人</th>
        <th>收信人</th>
        <th>是否已读</th>
        <th>创建时间</th>
        <th>更新时间</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>

{volist name='list' id='vo'}
      <tr>
        <td><input type="checkbox" name="mid[]" class="id " title=""  lay-skin="primary" value="{$vo.mid}"></td>
        <td>{if $vo.type == 0}<i class="layui-icon">&#xe645;</i> {elseif $vo.type == 1} <i class="fa fa-envelope-o" aria-hidden="true"></i>{/if} </td>
        <td>{if $vo.type== 0}通知{elseif $vo.type== 1}私信{/if}</td> 
        <td><a href="javascript:;" class="title" data-url="{:url('message/content',['mid'=>$vo.mid])}" >{$vo.title}</a></td>
        <td>{if $vo.form_uid ==0}系统{/if}</td>
        <td>{$vo.to_username}</td>
        <td>
       {if $vo.is_read ==1}<span class="layui-badge layui-bg-blue">已读</span>{else}<span class="layui-badge layui-bg-gray">未读</span>{/if}
        </td>
        <td>{$vo.create_time|date="Y-m-d H:i:s"}</td>
        <td>{if $vo.update_time}{$vo.update_time|date="Y-m-d H:i:s"}{/if}</td>
        <td>
        <div class="layui-btn-group">
          <button class="layui-btn layui-btn-sm layui-btn-primary" onclick="del('{:url("message/del",array("mid"=>$vo["mid"]))}')"> <i class="layui-icon">&#xe640;</i></button>
         </div>
 </td>
      </tr>
{/volist}

    </tbody>
  </table>

<!-- 搜索为空显示 -->
{if empty($list)}
 <div class="layui-form-item">
    <div class="empty">
     <div class="img"></div>
     <p>暂无内容</p></div>
 </div>
</div>
{/if}
</div>

<div id="pages">{$page|raw}</div>
<div class="layui-btn-group demoTable">
  <button class="layui-btn layui-btn-primary" id="del" data-type="getCheckData"> <i class="layui-icon">&#xe640;</i> 批量删除</button>
</div>

<script>
$(function(){
//全选批量删除
        var id = [];
        var url ="{:url('message/del')}"; //请求的url
        var data = {mid:id};   //传递的表单数据
        var delButton = "#del"; //删除节点class 或者ID
        var checkboxClass = ".id"; //多选框class

         $(delButton).click(function(){
              $(checkboxClass).each(function() {
              if(this.checked == true){
                   id.push($(this).val()); 
              }
              });              
         if(id.length == 0){
            parent.layer.alert('你没有选中任何分类',{title:'批量删除提示'});
         }else{
                     var index = parent.layer.confirm('批量删除后，数据不可恢复', {
                      btn: ['确定删除','取消'] //按钮
                      ,title:'是否批量删除'
                      ,shadeClose:true
                      ,icon: 3
                      ,anim: 5  //动画类型
                    }, function(){
                       parent.layer.close(index);
                    // 确定ajax 删除数据
                                $.post(url,data        
                                     ,function(json){
                                      if(json.code == 0){
                                          layer.msg(json.msg);
                                               setTimeout(function(){ 
                                                     window.location.reload();  //页面刷新
                                                },1000);
                                           }
                                         }
                                       );

                    }, function(){
                       // 取消

                    });

         }

    });

$("#add").on("click",function(){
  blank('{:url("message/add")}','添加消息','780px','80%');
});


});
</script>
</body>

</html>